package com.qf.business.goods.controller;

import com.qf.business.goods.service.GoodsInfoService;
import com.qf.data.base.r.R;
import com.qf.data.base.r.Rs;
import com.qf.data.goods.vo.input.GoodsInput;
import com.qf.data.goods.vo.output.GoodsFengMian;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/goods")
@Slf4j
public class GoodsController {

    @Autowired
    private GoodsInfoService goodsInfoService;

    @RequestMapping("/list")
    public R list(){
        List<GoodsFengMian> goodsFengMians = goodsInfoService.querySystemList();
        return Rs.create(goodsFengMians);
    }

    /**
     * 商品的新增
     * @return
     */
    @RequestMapping("/insert")
    public R insert(@Valid GoodsInput input){
       log.info("[goods insert] - 新增商品 - {}",input);
        goodsInfoService.insert(input);
        return Rs.create(true);
    }
}
